题目地址 (opens new window)
解题代码
public int hammingWeight(int n) { int cnt = 0; while(n != 0) { n = n & (n - 1); cnt ++; } return cnt; }
← LeetCode 交点 LeetCode 分割数组 →